Add api last_photo

Brightcells 8 年之前
父节点
当前提交
32429641cc
共有 3 个文件被更改,包括 24 次插入2 次删除
  1. 13 0
      main.py
  2. 2 2
      minipai2.conf
  3. 9 0
      utils/tv.py

+ 13 - 0
main.py

@@ -17,6 +17,7 @@ from utils.boxinfo import get_box_status, get_mac_address
17 17
 from utils.logit import log_request_arguments, logit
18 18
 from utils.sqlite import (CREATE_INDEX1, CREATE_INDEX2, CREATE_TABLE_STMT, DELETE_RECORD_STMT, INSERT_RECORD_STMT,
19 19
                           SELECT_MAX_PHOTO_ID_STMT, SELECT_ORIGIN_PATH_STMT)
20
+from utils.tv import get_last_photo_path
20 21
 
21 22
 
22 23
 define('host', default='127.0.0.1', help='run on the given host', type=str)
@@ -294,6 +295,16 @@ class BoxInfoHandler(RequestHandler):
294 295
         })
295 296
 
296 297
 
298
+class LastPhotoHandler(RequestHandler):
299
+    def post(self):
300
+        self.write({
301
+            'status': 200,
302
+            'data': {
303
+                'path': get_last_photo_path(),
304
+            }
305
+        })
306
+
307
+
297 308
 handlers = [
298 309
     (r'/', HelloHandler),
299 310
     (r'/session_start', SessionStartHandler),
@@ -303,6 +314,8 @@ handlers = [
303 314
     (r'/delete_photo', DeletePhotoHandler),
304 315
     (r'/box_info', BoxInfoHandler),
305 316
     (r'/static/(.*)', StaticFileHandler, {'path': ROOT_PATH}),
317
+    # TV APP
318
+    (r'/last_photo', LastPhotoHandler),
306 319
 ]
307 320
 
308 321
 

+ 2 - 2
minipai2.conf

@@ -1,2 +1,2 @@
1
-version=0.0.3
2
-deldb=true
1
+version=0.0.4
2
+deldb=false

+ 9 - 0
utils/tv.py

@@ -0,0 +1,9 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+
4
+def get_last_photo_path():
5
+    try:
6
+        path = open('/ramfs/last_mv_pic', 'r').read().strip()
7
+    except:
8
+        path = ''
9
+    return path